package com.uobgroup.ews.uam.core.service.ldap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.uobgroup.ews.uam.core.dao.ldap.LDSDao;
import com.uobgroup.ews.uam.core.domain.SecurityGroup;
import com.uobgroup.ews.uam.core.model.Group;
import com.uobgroup.ews.uam.core.model.Person;

@Service
@Transactional
public class LDSServiceImpl implements LDSService{
	
	@Autowired
	LDSDao ldsDao;
		
	public Person findUser(String username)
	{
		return ldsDao.findUser(username);
	}

	public Group findGroup(String groupName)
	{
		return ldsDao.findGroup(groupName);
	}

	public String createUser(Person person)
	{
		return ldsDao.createUser(person);
	}

	public boolean deleteUser(Person person)
	{
		return ldsDao.deleteUser(person);		
	}

	public String createGroup(SecurityGroup group)
	{
		return ldsDao.createGroup(group);		
		
	}

	public boolean deleteGroup(SecurityGroup group)
	{
		return ldsDao.deleteGroup(group);
	}

	public boolean hasGroupByBaseDN(String roleName, String baseDN)
	{
		return ldsDao.hasGroupByBaseDN(roleName, baseDN);
	}

	public boolean addAttribute(Person person, String attName, String attValue)
	{
		return ldsDao.addAttribute(person, attName, attValue);
	}

	public boolean updateAttribute(Person person, String attName, String attValue)
	{
		return ldsDao.updateAttribute(person, attName, attValue);
	}

	public boolean hasAttribute(Person person, String attName)
	{
		return ldsDao.hasAttribute(person, attName);
	}

   @Override
   public void assignChildGroupToParent(SecurityGroup parent, SecurityGroup child) {
      ldsDao.assignChildGroupToParent(parent, child);
   }

   @Override
   public void unassignChildGroupFromParent(SecurityGroup parent, SecurityGroup child) {
      ldsDao.unassignChildGroupFromParent(parent, child);
   }

   @Override
   public void assignUserToProfile(SecurityGroup parent, SecurityGroup child) {
      ldsDao.assignUserToProfile(parent, child);
   }

   @Override
   public void unassignUserFromProfile(SecurityGroup parent, SecurityGroup child) {
      ldsDao.unassignUserFromProfile(parent, child);
   }

   @Override
   public Group findGroupByBaseDN(String groupName, String baseDn) {
      return ldsDao.findGroupByBaseDN(groupName, baseDn);
   }

   
}
